package cn.zust.itcost.mapper;

import cn.zust.itcost.entity.graph.node.JobNode;
import org.springframework.boot.autoconfigure.batch.BatchProperties;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface JobRepository extends Neo4jRepository<JobNode, Long> {



        // 基于技能匹配的职位推荐
        @Query("MATCH (u:User)-[:HAS_SKILL]->(s:Skill)<-[:REQUIRES]-(j:Job) " +
                "WHERE u.id = $userId " +
                "RETURN j, COUNT(s) AS skillMatchCount " +
                "ORDER BY skillMatchCount DESC LIMIT 10")
        List<BatchProperties.Job> recommendJobsBySkill(@Param("userId") Long userId);

        // 基于同事申请的职位推荐（二度关系）
        @Query("MATCH (u:User)-[:WORKS_WITH]->(colleague:User)-[:APPLIED]->(j:Job) " +
                "WHERE u.id = $userId AND NOT (u)-[:APPLIED]->(j) " +
                "RETURN j, COUNT(colleague) AS colleagueCount " +
                "ORDER BY colleagueCount DESC LIMIT 10")
        List<JobNode> recommendJobsByColleagues(@Param("userId") Long userId);

}
